
import { Style, Icon, Text, Fill, Circle, Stroke } from 'ol/style'
import imagesMap from '@/components/BaseMap/tools/gisImage.js'

export const geomStyles = (type, option) => {
  if (type === 'airport') {
    return new Style({
      image: new Icon({
        anchor: [0.5, 0.9],
        src: imagesMap['airport']
      }),
      text: new Text({
        // 文字内容
        text: option?.name,
        // 位置
        textAlign: 'center',
        // 基准线
        textBaseline: 'top',
        offsetY: -150,
        textShadow: ' 0 0 10px red,0 0 20px red,0 0 30px red,0 0 40px red',
        // 文字样式
        font: 'normal 22px SourceHanSansCN-Medium',
        // backgroundFill: new Fill({
        //   color: '#1890FF'
        // }),
        // padding: [3, 6, 3, 6],
        // 文字颜色
        fill: new Fill({
          color: 'rgba(255, 255, 255, 1)'
        })
      })
    })
  } else if (type === 'structure') {
    let img
    switch (option?.structureType) {
      case 1:
        img = imagesMap['gangkou']
        break
      case 2:
        img = imagesMap['matou']
        break
      case 3:
        img = imagesMap['chuanzha']
        break
      case 4:
        img = imagesMap['fuwuqu']
        break
      case 5:
        img = imagesMap['jiayouzhan']
        break
      case 6:
        img = imagesMap['qiaoliang']
        break
      case 7:
        img = imagesMap['tonghangjianzhuwu']
        break
    }
    return new Style({
      image: new Icon({
        src: img
      })
    })
  } else if (type === 'question') {
    return new Style({
      image: new Icon({
        src: imagesMap['wenti']
      })
    })
  } else if (type === 'route') {
    return new Style({
      stroke: new Stroke({
        width: 2,
        color: 'red'
      })
    })
  } else if (type === 'start') {
    return new Style({
      image: new Icon({
        src: imagesMap['start'],
        anchor: [0.5, 0.8],
        crossOrigin: ''
      })
    })
  } else if (type === 'end') {
    return new Style({
      image: new Icon({
        src: imagesMap['end'],
        anchor: [0.5, 0.8],
        crossOrigin: ''
      })
    })
  } else if (type === 'accident') {
    return new Style({
      image: new Icon({
        src: imagesMap['accident']
      })
    })
  } else if (type === 'droneRoute') {
    return new Style({
      stroke: new Stroke({
        width: 4,
        color: '#5798FF',
        lineDash: [10]
      })
    })
  } else if (type === 'routeStop') {
    return new Style({
      image: new Circle({
        // 半径
        radius: 5,
        // 填充样式
        fill: new Fill({
          color: 'white'
        }),
        // 边界样式
        stroke: new Stroke({
          color: '#5798FF',
          // 边界宽度
          width: 2
        })
      })
    })
  } else if (type === 'geoMarker') {
    return new Style({
      image: new Icon({
        anchor: [0.5, 0.5],
        src: imagesMap['uav'],
        crossOrigin: '',
        // scale: [1, 1],
        scale: 0.15,
        rotateWithView: true
      })
    })
  }
}

